<?php
include_once 'header_php.php';
$title='Recherche';
include_once 'header_html.php';
?>
<div class="wrapper">
    <div class="container span8 offset2">
        <ul class="nav nav-tabs" id="myTab" data-tabs="tabs">
        <li class="active" ><a href="#membre" data-toggle="tab">Membre</a></li>
        <li><a href="#asso" data-toggle="tab">Association</a></li>
        <?php
            if ($p->IsMemberOf("BDE", $db)&& $p->IsConnected()){
        echo '<li><a href="#avancee" data-toggle="tab">Recherche avancée</a></li>';
            } ?>
        </ul>

        <div class="tab-content">
        <div class="tab-pane active" id="membre" onClick="$('#myTab a[href=\"#membre\"]').tab('show');">
            <form class="form-horizontal" action="result.php" method="POST" accept-charset="UTF-8">
                <fieldset>
                    <legend>Rechercher un membre</legend>
                    <div class="control-group">
                        <div class="controls">
                            <input type="hidden" name="type" value="membre">
                            <input id="query" name="query" type="text" class="input-xlarge" placeholder="Votre recherche">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="champ">Rechercher suivant </label>
                        <div class="controls">
                            <select id="champ" name="champ">
                                <option value="login">Login</option>
                                <option value="nom">Nom</option>
                                <option value="prenom">Prénom</option>
                            </select>
                            
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary">Rechercher</button>
                    </div>

                </fieldset>
            </form>          
        </div>
            
        <div class="tab-pane" id="asso" onClick="$('#myTab a[href=\"#asso\"]').tab('show');">
            <form class="form-horizontal" action="result.php" method="POST" accept-charset="UTF-8">
                <fieldset>
                    <legend>Rechercher une association</legend>
                    <div class="control-group">
                        <div class="controls">
                            <input type="hidden" name="type" value="asso">
                            <input id="query" name="query" type="text" class="input-xlarge" placeholder="Votre recherche">
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="submit" class="btn btn-primary">Rechercher</button>
                    </div>

                </fieldset>
            </form> 
        </div>
            <?php 
                if ($p->IsMemberOf("BDE", $db)&& $p->IsConnected()){
                    echo '<div class="tab-pane" id="avancee" onClick="$(\'#myTab a[href=\"#avancee\"]\').tab(\'show\');">';      
                    echo '<form class="form-horizontal" action="listing.php" method="POST" accept-charset="UTF-8">';
                    echo '<fieldset>';
                    echo '<legend>Choisir les gens</legend>';
                    echo '<div class="control-group">';
                        echo '<label class="control-label" for="personnes">Rechercher</label>';
                        echo '<div class="controls">';
                            echo '<select id="personnes" name="personnes">';
                                echo '<option value="bureaux complet">Bureau complet</option>';
                                echo '<option value="Président">Président</option>';
                                echo '<option value="Secretaire">Secrétaire</option>';
                                echo '<option value="Trésorier">Trésorier</option>';
                                echo '<option value="membre">Tous les membres</option>';
                            echo '</select>';
                            
                        echo '</div>';
                    echo '</div>';

                echo '</fieldset>';
                echo '<fieldset>';
                    echo '<legend>Choisir les assos</legend>';
                    echo '<div class="control-group">';
                        echo '<label class="control-label" for="asso[]"> </label>';
                        echo '<div class="controls">';
                            
                                $sql="SELECT nom FROM association ORDER BY nom;";
                                $query= new DbQuery($db,$sql);
                                $query->SendQuery();
                                while($result=$query->GetResult()){
                                    echo '<input type="checkbox" name="asso[]" id="'.$result['nom'].'" value="'.$result['nom'].'" />  '.$result['nom'].'<br/>';
                                }
                            
                        echo '</div>';
                    echo '</div>';

                echo '</fieldset>';
                echo '<fieldset>';
                    echo '<legend>Choisir la période</legend>';
                    echo '<div class="control-group">';
                        echo '<label class="control-label" for="debut">Entre </label>';
                        echo '<div class="controls">';
                            echo '<div class="controls">';
                            echo '<select id="debut" name="debut">';
                                
                                    $sql="SELECT semestre FROM membreasso GROUP BY semestre ORDER BY cast(substring(semestre,2,2) AS integer);";
                                    echo $sql;
                                    $query= new DbQuery($db,$sql);
                                    $query->SendQuery();
                                    while($result=$query->GetResult()){
                                        echo '<option value="'.$result['semestre'].'" id="'.$result['semestre'].'" />  '.$result['semestre'].'</option>';
                                    }
                               
                            echo '</select>';
                            
                        echo '</div>';                           
                        echo '</div>';
                        echo '<label class="control-label" for="fin">Et </label>';
                        echo '<div class="controls">';
                            echo '<div class="controls">';
                            echo '<select id="fin" name="fin">';
                                
                                    $sql="SELECT semestre FROM membreasso GROUP BY semestre ORDER BY cast(substring(semestre,2,2) AS integer);";
                                    $query= new DbQuery($db,$sql);
                                    $query->SendQuery();
                                    while($result=$query->GetResult()){
                                        echo '<option value="'.$result['semestre'].'" id="'.$result['semestre'].'" />  '.$result['semestre'].'</option>';
                                    }
                                
                            echo '</select>';
                        echo '</div>';
                        echo '</div>';
                    echo '</div>';
                    echo '<div class="form-actions">';
                        echo '<button type="submit" class="btn btn-primary">Obtenir un listing</button>';
                    echo '</div>';

                echo '</fieldset>';
            echo '</form>';          
        echo '</div>';}
            ?>
           
        </div>

        <script>
        $(function () {
            $('#myTab a:first').tab('show');
        })
        </script>
    </div>
</div>

<?php //include_once 'footer.php'; ?>

    </body>
</html>